using System.Collections.Generic;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpModelExpression : OracleLpExpression
	{
		protected OracleLpModelExpressionType m_vModelExpressionType;

		protected OracleLpAnalyticFunction m_vAnalyticFunction;

		public OracleLpModelExpressionType ModelExpressionType
		{
			get
			{
				return m_vModelExpressionType;
			}
			set
			{
				m_vModelExpressionType = value;
			}
		}

		public OracleLpAnalyticFunction AnalyticFunction
		{
			get
			{
				return m_vAnalyticFunction;
			}
			set
			{
				m_vAnalyticFunction = value;
			}
		}

		public OracleLpModelExpression(OracleLpStatementElement parent)
			: base(parent)
		{
			m_vExpressionType = OracleLpExpressionType.MODEL_EXPRESSION;
		}

		public override void EvaluateDatatype()
		{
		}

		public override IList<OracleLpExpression> GetAllTerminalExpressions()
		{
			if (m_vAllTerminalExpressions == null)
			{
				switch (m_vModelExpressionType)
				{
				case OracleLpModelExpressionType.ANALYTIC_FUNCTION:
					m_vAllTerminalExpressions = m_vAnalyticFunction.Arguments[0].Expression.GetAllTerminalExpressions();
					foreach (OracleLpExpression vAllTerminalExpression in m_vAllTerminalExpressions)
					{
						if (vAllTerminalExpression.ParentExpression == null)
						{
							vAllTerminalExpression.ParentExpression = this;
						}
					}
					break;
				default:
					m_vAllTerminalExpressions = base.GetAllTerminalExpressions();
					break;
				}
			}
			return m_vAllTerminalExpressions;
		}
	}
}
